home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWCollec / Include / SLSrtArr.h < prev   
Encoding:
Text File  |  1996-04-25  |  2.9 KB  |  92 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLSrtArr.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef SLSRTARR_H
  11. #define SLSRTARR_H
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. //========================================================================================
  18. // Forward Declarations
  19. //========================================================================================
  20.  
  21. struct FW_SPrivSortedArray;
  22. typedef FW_SPrivSortedArray* FW_HSortedArray;
  23.  
  24. //========================================================================================
  25. // Typedefs
  26. //========================================================================================
  27.  
  28. typedef int (*FW_SortedArray_CompareFunction)(void* first, void* second);
  29.     // return negative integer if first is less than second
  30.     // return 0 if first == second
  31.     // return positive integer if first is greater than second
  32.  
  33. //========================================================================================
  34. // Extern C Methods
  35. //========================================================================================
  36.  
  37. FW_EXTERN_C_BEGIN
  38.  
  39. #if defined(FW_ODFLIB_IMPORT)
  40. #pragma import on
  41. #elif defined(FW_ODFLIB)
  42. #pragma export on
  43. #endif
  44.  
  45. FW_HSortedArray    FW_PrivSortedArray_New(FW_PlatformError* error,
  46.                                         FW_SortedArray_CompareFunction compare);
  47.  
  48. void    FW_PrivSortedArray_Dispose(FW_HSortedArray self);
  49.  
  50. long FW_PrivSortedArray_GetLength(FW_HSortedArray self);
  51.     // Retrieve the number of items
  52.  
  53. void* FW_PrivSortedArray_GetItemAt(FW_HSortedArray self, long index);
  54.     // Retrieve the item at location index
  55.  
  56. FW_Boolean FW_PrivSortedArray_Find(FW_HSortedArray self, 
  57.                             void* item,
  58.                             long* index);
  59.     // Do a binary search for item
  60.     // If item is found, function result is true and index is the location of the item
  61.     // If item is not found, result is false, and index is location where item
  62.     // would be inserted
  63.  
  64. void FW_PrivSortedArray_Insert(FW_HSortedArray self, 
  65.                             void* newItem,
  66.                             long index,
  67.                             FW_PlatformError* error);
  68.     // Item is inserted into the array at location index.
  69.     // It is client's responsiblity to insert item in a location
  70.     // that preserves sorting. Use FW_PrivSortedArray_Find
  71.     // to find the correct location
  72.  
  73.  
  74. void FW_PrivSortedArray_Add(FW_HSortedArray self, 
  75.                             void* newItem,
  76.                             long* index,
  77.                             FW_PlatformError* error);
  78.     // Item is inserted into the array in the location that preserves sorting.
  79.     // The location is returned in *index.
  80.     // Items must be unique, so it is an error if there already exists an item
  81.     // in the array which when compared to newItem returns kEqual
  82.  
  83. #if defined(FW_ODFLIB_IMPORT)
  84. #pragma import off
  85. #elif defined(FW_ODFLIB)
  86. #pragma export off
  87. #endif
  88.  
  89. FW_EXTERN_C_END
  90.  
  91. #endif
  92.